package ch12;

class ThreadEx12 {
	public static void main(String args[]) {
		RunnableImpl r = new RunnableImpl();
		Thread t1 = new Thread(r);
		Thread t2 = new Thread(r);

		t1.start();
		t2.start();
	}
}

class RunnableImpl implements Runnable {
	int iv = 0;

	public void run() {
		int lv = 0;
		String name = Thread.currentThread().getName();

		while (lv < 3) {
			System.out.println(name + " Local Var:" + ++lv);
			System.out.println(name + " Instance Var:" + ++iv);
			System.out.println();
		}
	}
}
/*
Thread-0 Local Var:1
Thread-1 Local Var:1
Thread-0 Instance Var:1
Thread-1 Instance Var:2


Thread-1 Local Var:2
Thread-0 Local Var:2
Thread-1 Instance Var:3

Thread-0 Instance Var:4

Thread-1 Local Var:3
Thread-0 Local Var:3
Thread-1 Instance Var:5

Thread-0 Instance Var:6
*/
